library(DMC21cent)

Subject Level Summary Plots

Exploring SEX

sl_summary(adsl,
           vars = "SEX",
           kinds = "bar_binom",
           titles = "Female Subjects (%)",
           trt = "TRT01P",
           digits = 1,
           base_size = 18)

sl_summary(adsl,
          vars = list("SEX" = "M"),  # `list()` only works for `bar_binom` kind
          kinds = "bar_binom",
          titles = "Male Subjects (%)",
          trt = "TRT01P")

sl_summary(adsl, 
           vars = c(list("SEX" = "M"), "SEX"),
           kinds = c("bar_binom"),
           trt = "TRT01P",
           show_plots = TRUE,
           titles = c("Male Subjects (%)", "Female Subjects (%)"),
           ncol = 1, 
           base_size = 14)


# or you can save the output of sl_summary() in an object.

Exploring RACE

sl_summary(adsl,
            vars = "RACE",
            kinds = "bar_stack",        # `bar_stack` visualization will be applied for both `SEX` and `RACE`
            titles = "RACE (%)",  # Put `NA` when you don't need to have a main title for your plot
            trt = "TRT01P")

sl_summary(adsl,
            vars = c("RACE", "SEX"),
            kinds = c("bar_stack"),        # `bar_stack` visualization will be applied for both `SEX` and `RACE`
            titles = c("RACE (%)", NA),  # Put `NA` when you don't need to have a main title for your plot
            trt = "TRT01P")

Exploring AGE

sl_summary(adsl,
           vars = "AGEGR1",
           relevel_vec = list(adsl %>% pull(AGEGR1) %>% levels() %>% rev()),
           kinds = "bar_stack",        # `bar_stack` visualization will be applied for both `SEX` and `RACE`
           titles = "AGE Group 1 (%)",  # Put `NA` when you don't need to have a main title for your plot
           trt = "TRT01P")

sl_summary(
  adsl,
  vars = "AGE",
  kinds = "box",
  titles = "Age [years]",
  trt = "TRT01A",
  breaks_vec = list(c(60, 70, 80, 90)),
  show_plots = TRUE,
  base_size = 18
)

Show same plot but with th gridlines set to the overall 5-number summary. These are informative gridlines.

sl_summary(
  adsl,
  vars = "AGE",
  kinds = "box",
  titles = "Age [years]",
  trt = "TRT01A",
  show_plots = TRUE,
  base_size = 18
)

plots <- sl_summary(adsl,
            vars = c("SEX", "AGE"),
            kinds = c("bar_stack", "box"),
            titles = c("Female Subjects (%)", "AGE (years)"),
            trt = "TRT01A",
            breaks_vec = list(NULL, c(60, 70, 80, 90)),
            show_plots = FALSE)

patchwork::wrap_plots(plots, ncol = 1)


# In case you want to save your plot:
# ggplot2::ggsave(
#        plots[[1]],
#        filename = here::here("Your_File", "Figure01_sex_f.png"),
#        width = 4,
#        height = 2
#      )

Adverse Event Summary Plots

Forest Plot

ae_summary(adae = adae,
            adsl = adsl,
            kind = "forest",
            pval_cutoff = 0.6,
            title = "Adverse events (Preferred Terms), hazard ratios",
            subtitle = "Xanomeline High Dose vs. Placebo, Safety analysis set",
            caption = "Hazard ratio calculated from a Cox regression model."
           )

Rate Plot

ae_summary(adae = adae,
          adsl = adsl,
          kind = "rate",
          reord_type_rateplot = "diff",
          title = "Adverse events (Preferred Terms), incidence rates",
          subtitle = "Xanomeline High Dose vs. Placebo, Safety analysis set",
          caption = ""
         )

ae_summary(adae = adae,
          adsl = adsl,
          kind = "rate",
          reord_type_rateplot = "trt",
          title = "Adverse events (Preferred Terms), incidence rates",
          subtitle = "Xanomeline High Dose vs. Placebo, Safety analysis set",
          caption = ""
         )

ae_summary(adae = adae,
          adsl = adsl,
          kind = "rate",
          reord_type_rateplot = "placebo",
          title = "Adverse events (Preferred Terms), incidence rates",
          subtitle = "Xanomeline High Dose vs. Placebo, Safety analysis set",
          caption = ""
         )

Swimmer Plot

ae_summary(adae = adae,
          adsl = adsl,
          kind = "swimmer",
          title = "Adverse event profiles",
          subtitle = "Patients with at least one treatment-emergent serious or severe AE, Xanomeline High Dose, Safety analysis set",
          caption = "The red and bold fonts show severe and serious events respectively. \n The grey box indicates individual patient Xanomeline exposure."
          )

Volcano Plot

ae_summary(adae = adae,
          adsl = adsl,
          kind = "volcano_pval",
          pval_cutoff = 1,
          adjpval_cutoff = 0.9,
          title = "Comparison of adverse events (preferred terms) by treatment",
          subtitle = "Xanomeline High Dose vs. Placebo, Safety analysis set",
          caption = "P-value is from a Cox regression model."
         )

ae_summary(adae = adae,
          adsl = adsl,
          kind = "volcano_adjpval",
          pval_cutoff = 1,
          adjpval_cutoff = 0.9,
          title = "Comparison of adverse events (preferred terms) by treatment",
          subtitle = "Xanomeline High Dose vs. Placebo, Safety analysis set",
          caption = "P-value is from a Cox regression model, adjusted for multiple comparisons (based on false discovery rate)."
          )

Laboratory Summary Plots

Abnormal Plot

lab_summary(adlb = adlbc,
           kind = "abnormal",
           param_filter = "Cholesterol (mmol/L)",
           selected_visit = c("Baseline", "Week 2", "Week 4", "Week 6", "Week 8", "End of Treatment"),
           title = NULL  # an auto generated title
          )

Box Plot

lab_summary(adlb = adlbc,
           kind = "box",
           param_filter = "Cholesterol (mmol/L)",
           selected_visit = c("Baseline", "Week 2", "Week 4", "Week 6", "Week 8", "End of Treatment"),
           title = NULL  # an auto generated title
          )

Shift Plot

lab_summary(adlb = adlbhy,
           kind = "shift",
           param_filter = "Alanine Aminotransferase (U/L)",
           title = NULL,  # automatically generated title,
           shift_breaks_vec = NULL, # automatically generated 25X breaks, and 50X labels
           shift_alpha = 0.5,
           shift_size = 3
           )

Spaghetti Plot

lab_spaghetti(adlb = adlbc,
              param_filter = "Bilirubin (umol/L)",
              selected_visit = c("Baseline", "Week 2", "Week 4", "Week 6", "Week 8", "End of Treatment"))

lab_spaghetti(adlb = adlbc,
              param_filter = "Creatine Kinase (U/L)",
              axis_tick_size = 8,
              x_axis_wrap = 6,
              selected_visit = c("Baseline", "Week 2", "Week 4", "Week 6", "Week 8", "End of Treatment"))

Patient Profile

Summary table

patient_profile(data = adsl,
                usubjid = "02-718-1371",
                kind = 'summary')
USUBJID SEX RACE AGE ARM SITEID First Exposure to TRT Last Exposure to TRT
02-718-1371 F WHITE 69 Xanomeline High Dose 718 2013-04-26 2013-08-01

Laboratory

patient_profile(data = adlbc,
                usubjid = "02-718-1371",
                kind = 'lab',
                filter_safety_flag_lab = "Y",
                ncol_lab = 1,
                transform_lab = 'log',
                params_lab = c("Alanine Aminotransferase (U/L)",
                                "Aspartate Aminotransferase (U/L)",
                                "Bilirubin (umol/L)"),
                selected_visit = c("Baseline", "Week 2", "Week 4", "Week 6", "Week 8", "End of Treatment"))

Adverse Event

patient_profile(data = adae,
                usubjid = "02-718-1371",
                kind = 'ae',
                str_wrap_ae_cm = 25,
                height_ae = 250,
                color_ae = c("#5291DD", "#EC9A1E", "#CC0022"))

Concomitant Medications

patient_profile(data = adcm,
                usubjid = "02-718-1371",
                str_wrap_ae_cm = 25,
                kind = 'cm',
                color_cm = "#911EB4")

One Page result

USUBJID SEX RACE AGE ARM SITEID First Exposure to TRT Last Exposure to TRT
02-718-1371 F WHITE 69 Xanomeline High Dose 718 2013-04-26 2013-08-01